const api = {
  sys: {
    tables: 'tables',
  },
};
function toUnderline(str: string, level: number) {
  if (level > 1) {
    return str;
  }
  return str.replace(/([A-Z])/g, '-$1').toLowerCase();
}
function setApiPrefix(api: Record<string, any>, prefix = '', level = 0) {
  for (const key in api) {
    if (typeof api[key] === 'object' && api[key] !== null) {
      setApiPrefix(
        api[key],
        (level == 0 ? '/api' : '') + toUnderline(prefix, level) + '/' + (api.key || key),
        level + 1
      );
    } else {
      api[key] = prefix + (api[key].startsWith('/') ? api[key] : '/' + api[key]);
    }
  }
}
setApiPrefix(api);
export default api;
